package com.alm.handle.service.impl;



import com.alm.handle.core.domain.entity.SysDevInfo;
import com.alm.handle.core.domain.entity.SysDevModel;
import com.alm.handle.core.domain.entity.rq.SysDevModelRq;
import com.alm.handle.mapper.SysDevCurrentDataMapper;
import com.alm.handle.mapper.SysDevInfoMapper;
import com.alm.handle.mapper.SysDevModelMapper;
import com.alm.handle.service.ISysDevModelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDevModelServiceImpl implements ISysDevModelService {

    @Autowired
    private SysDevModelMapper sysDevModelMapper;

    @Override
    public List<SysDevModel> selectModelListList() {
        return sysDevModelMapper.selectList(new QueryWrapper<>());
    }

    @Override
    public List<SysDevModel> selectModelListList(Integer type) {
        QueryWrapper queryWrapper=new QueryWrapper();
        if(type!=null&&type!=0){
            queryWrapper.eq("dev_type",type);
        }
        return sysDevModelMapper.selectList(queryWrapper);
    }

    @Override
    public int upModel(SysDevModelRq devModel) {
        SysDevModel sysDevModel= new SysDevModel();
        BeanUtils.copyProperties(devModel,sysDevModel);
        return sysDevModelMapper.updateById(sysDevModel);
    }

    @Override
    public List<SysDevModel> selectModelList(SysDevModel sysDevModel) {
        return sysDevModelMapper.selectModelList(sysDevModel);
    }

    @Override
    public int updateDevModelInfo(SysDevModel sysDevModel) {
        return sysDevModelMapper.updateDevModelInfo(sysDevModel);
    }

    @Override
    public int delDevModelInfo(Long modelId) {
        return sysDevModelMapper.deleteById(modelId);
    }

    @Override
    public int addDevModel(SysDevModel sysDevModel) {
        sysDevModel.setAddTime(System.currentTimeMillis() / 1000);
        return sysDevModelMapper.insert(sysDevModel);
    }
}
